package br.urca.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Embeddable
public class DocumentoEmitidoPK implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@Column(name = "cdalucur", columnDefinition = "VARCHAR(11)")
	private String matricula;
	
	@Column(name = "tipodoc")
	private short tipoDocumento;
	
	@Column(name = "emissao")
	@Temporal(TemporalType.DATE)
	private Date emissao;
	
	public DocumentoEmitidoPK() { }

	public DocumentoEmitidoPK(String matricula, short tipoDocumento,
			Date emissao) {
		super();
		this.matricula = matricula;
		this.tipoDocumento = tipoDocumento;
		this.emissao = emissao;
	}

	public String getMatricula() {
		return matricula;
	}

	public void setMatricula(String matricula) {
		this.matricula = matricula;
	}

	public short getTipoDocumento() {
		return tipoDocumento;
	}

	public void setTipoDocumento(short tipoDocumento) {
		this.tipoDocumento = tipoDocumento;
	}

	public Date getEmissao() {
		return emissao;
	}

	public void setEmissao(Date emissao) {
		this.emissao = emissao;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((emissao == null) ? 0 : emissao.hashCode());
		result = prime * result
				+ ((matricula == null) ? 0 : matricula.hashCode());
		result = prime * result + tipoDocumento;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DocumentoEmitidoPK other = (DocumentoEmitidoPK) obj;
		if (emissao == null) {
			if (other.emissao != null)
				return false;
		} else if (!emissao.equals(other.emissao))
			return false;
		if (matricula == null) {
			if (other.matricula != null)
				return false;
		} else if (!matricula.equals(other.matricula))
			return false;
		if (tipoDocumento != other.tipoDocumento)
			return false;
		return true;
	}
	
}
